
function [SE_ITT,SE_SNT,SE_ITT_Tonly]=power_pooled(n,C,tau,sigma,pi,f)

%Initialize distribution statistics
mu_k=zeros(1,length(pi));
eta_k=zeros(1,length(pi));

%Calculate distribution statistics
for i=1:length(pi);
mu_k(i)=pi(i) *f(i);
eta_k(i)=pi(i)^2 *f(i);
end;

mu=sum(mu_k);
psi=0;if pi(1)==0; psi=f(1);end;
muS = 1-mu-psi;
eta=sum(eta_k); 
etaT=eta/(1-psi)-mu^2/(1-psi)^2;

%Standard Errors for Pooled Model (Theorem 1)
SE_ITT = (n*tau*((1-psi)*etaT/mu^2 +1/(psi*(1-psi)))+sigma*(1/mu +1/psi)).^0.5/(n*C)^0.5;
SE_SNT = (n*tau*((1-psi)*etaT/muS^2+1/(psi*(1-psi)))+sigma*(1/muS+1/psi)).^0.5/(n*C)^0.5;

%Standard Errors: including within-cluster controls as pure controls
SE_ITT_Tonly = (n*tau*(eta-mu^2)/(mu^2*(1-mu)^2) + sigma/(mu*(1-mu))).^0.5/(n*C)^0.5;

end 



